<?php
/**
 * Created by PhpStorm.
 * User: xaq
 * Date: 2017/6/1
 * Time: 11:12
 */

namespace app\api\controller\v2;


use app\api\controller\BaseController;

class Professional extends BaseController
{
    public function getDataByHtml(){
        $matches = [];
        //int preg_match_all ( string pattern, string subject, array matches [, int flags] )
        $subject = file_get_contents("http://baike.baidu.com/link?url=s0DgT2cmfPQb4xbiqwZn7jhhA_kHcEEW2Cb__WjavZqbbii3LSEUtF311ysdddXqgDS8VrtVzYqYD6YbHZXUS0LdlBJgXsmwdvFf4KhkgXOQiOSEaepxckSL83wYiUrK");
        $pattern = "/<div class=\"para\" label-module=\"para\".*?>(0.{2,}?)<\/div>/ism";
        preg_match_all ( $pattern, $subject, $matches);
//        foreach($matches[1] as $match) {
//            print_r($match);
//        }

        $match = [[
            '01' => '哲学',
            'item' => [
                '0101' => '哲学类',
                'item' => [
                    '010101' => '哲学',
                    '010102' => '逻辑学',
                    '010103K' => '宗教学'
                ]
            ],
        ],[
            '02' => '经济学',
            'item' => [
                [
                    '0201'=> '经济学类',
                    'item' => [
                        '020101' => '经济学',
                        '020102' => '经济统计学',]
                ],[
                    '0202'=> '财政学类',
                    'item' => [
                        '020201K' => '财政学',
                        '020202' => '税收学',
                    ]
                ],[
                    '0203'=> '金融学类',
                    'item' => [
                        '020301K' => '金融学',
                        '020302' => '金融工程',
                        '020303' => '保险学',
                        '020304' => '投资学',
                    ]
                ],[
                    '0204' => '经济与贸易类',
                    'item' => [
                        '020401' => '国际经济与贸易',
                        '020402' => '贸易经济'
                    ]
                ]],
        ],[
            '03' => '法学',
            'item' => [
                [
                    '0301' => '法学类',
                    'item' => [
                        '030101K' => '法学',
                    ]
                ], [
                    '0302' => '政治学类',
                    'item' => [
                        '030201' => '政治学与行政学',
                        '030202' => '国际政治',
                        '030203' => '外交学'
                    ]
                ],[
                    '0303' => '外交学',
                ]
            ]
        ]
        ];
        return $match;
    }
}